<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8">
    <title>Performance Test of NumberTextBox</title>

    <style type="text/css">
      @import "../../themes/claro/document.css";
      @import "../css/dijitTests.css";
    </style>

    <!-- required: the default dijit theme: -->
    <link id="themeStyles" rel="stylesheet" href="../../../dijit/themes/claro/claro.css"/>

    <!-- required: dojo.js -->
    <script type="text/javascript" src="../../../dojo/dojo.js"
      data-dojo-config="isDebug: true, parseOnLoad: true"></script>

    <!-- only needed for alternate theme testing: -->
    <script type="text/javascript" src="../_testCommon.js"></script>

    <script type="text/javascript">
      dojo.require("dijit.dijit"); // optimize: load dijit layer
      dojo.require("dijit.form.TextBox");
      dojo.require("dijit.form.ValidationTextBox");
      dojo.require("dijit.form.NumberTextBox");
      dojo.require("dijit.form.Form");
      dojo.require("dojo.parser");  // scan page for widgets and instantiate them
    </script>

  </head>

  <body class="claro">
    <script>
      function performancetest() {
        console.log("Dojo version " + dojo.version);
        var startTime1 = (new Date()).getTime();
        dijit.byId("form1").reset();
        console.log("Time 1: Reset form with NumberTextBox-fields: " + ((new Date()).getTime() - startTime1) + " millis");

        var startTime2 = (new Date()).getTime();
        dijit.byId("form2").reset();
        console.log("Time 2: Reset form with ValidationTextBox-fields: " + ((new Date()).getTime() - startTime2) + " millis");

        var startTime3 = (new Date()).getTime();
        for (var i = 1; i <= 20; i++) {
			    var w = dijit.byId("input1_" + i);
			    if(dojo.version.major == 1 && dojo.version.minor == 2) {
			      w.set("value", i);
			    } else {
			      w.set("value", i);
			    }
			  }
        console.log("Time 3: Inserting value into NumberTextBox-fields: " + ((new Date()).getTime() - startTime3) + " millis");

        var startTime4 = (new Date()).getTime();
        for (var i = 1; i <= 20; i++) {
			    var w = dijit.byId("input2_" + i);
			    if(dojo.version.major == 1 && dojo.version.minor == 2) {
			      w.set("value", i);
			    } else {
			      w.set("value", i);
			    }
			  }
        console.log("Time 4: Inserting value into ValidationTextBox-fields: " + ((new Date()).getTime() - startTime4) + " millis");
      }
    </script>
      <form id="form1" data-dojo-type="dijit.form.Form" data-dojo-props='action:"", method:""'>
      <input id="input1_1" data-dojo-type="dijit.form.NumberTextBox" data-dojo-props='name:"input1", maxLength:"6", type:"text" '/>
      <input id="input1_2" data-dojo-type="dijit.form.NumberTextBox" data-dojo-props='name:"input1", maxLength:"6", type:"text" '/>
      <input id="input1_3" data-dojo-type="dijit.form.NumberTextBox" data-dojo-props='name:"input1", maxLength:"6", type:"text" '/>
      <input id="input1_4" data-dojo-type="dijit.form.NumberTextBox" data-dojo-props='name:"input1", maxLength:"6", type:"text" '/>
      <input id="input1_5" data-dojo-type="dijit.form.NumberTextBox" data-dojo-props='name:"input1", maxLength:"6", type:"text" '/>
      <input id="input1_6" data-dojo-type="dijit.form.NumberTextBox" data-dojo-props='name:"input1", maxLength:"6", type:"text" '/>
      <input id="input1_7" data-dojo-type="dijit.form.NumberTextBox" data-dojo-props='name:"input1", maxLength:"6", type:"text" '/>
      <input id="input1_8" data-dojo-type="dijit.form.NumberTextBox" data-dojo-props='name:"input1", maxLength:"6", type:"text" '/>
      <input id="input1_9" data-dojo-type="dijit.form.NumberTextBox" data-dojo-props='name:"input1", maxLength:"6", type:"text" '/>
      <input id="input1_10" data-dojo-type="dijit.form.NumberTextBox" data-dojo-props='name:"input1", maxLength:"6", type:"text" '/>
      <input id="input1_11" data-dojo-type="dijit.form.NumberTextBox" data-dojo-props='name:"input1", maxLength:"6", type:"text" '/>
      <input id="input1_12" data-dojo-type="dijit.form.NumberTextBox" data-dojo-props='name:"input1", maxLength:"6", type:"text" '/>
      <input id="input1_13" data-dojo-type="dijit.form.NumberTextBox" data-dojo-props='name:"input1", maxLength:"6", type:"text" '/>
      <input id="input1_14" data-dojo-type="dijit.form.NumberTextBox" data-dojo-props='name:"input1", maxLength:"6", type:"text" '/>
      <input id="input1_15" data-dojo-type="dijit.form.NumberTextBox" data-dojo-props='name:"input1", maxLength:"6", type:"text" '/>
      <input id="input1_16" data-dojo-type="dijit.form.NumberTextBox" data-dojo-props='name:"input1", maxLength:"6", type:"text" '/>
      <input id="input1_17" data-dojo-type="dijit.form.NumberTextBox" data-dojo-props='name:"input1", maxLength:"6", type:"text" '/>
      <input id="input1_18" data-dojo-type="dijit.form.NumberTextBox" data-dojo-props='name:"input1", maxLength:"6", type:"text" '/>
      <input id="input1_19" data-dojo-type="dijit.form.NumberTextBox" data-dojo-props='name:"input1", maxLength:"6", type:"text" '/>
      <input id="input1_20" data-dojo-type="dijit.form.NumberTextBox" data-dojo-props='name:"input1", maxLength:"6", type:"text" '/>
      </form>
      <br/>
      <form id="form2" data-dojo-type="dijit.form.Form" data-dojo-props='action:"", method:""'>
      <input id="input2_1" data-dojo-type="dijit.form.ValidationTextBox" data-dojo-props='name:"input1", maxLength:"6", type:"text" '/>
      <input id="input2_2" data-dojo-type="dijit.form.ValidationTextBox" data-dojo-props='name:"input1", maxLength:"6", type:"text" '/>
      <input id="input2_3" data-dojo-type="dijit.form.ValidationTextBox" data-dojo-props='name:"input1", maxLength:"6", type:"text" '/>
      <input id="input2_4" data-dojo-type="dijit.form.ValidationTextBox" data-dojo-props='name:"input1", maxLength:"6", type:"text" '/>
      <input id="input2_5" data-dojo-type="dijit.form.ValidationTextBox" data-dojo-props='name:"input1", maxLength:"6", type:"text" '/>
      <input id="input2_6" data-dojo-type="dijit.form.ValidationTextBox" data-dojo-props='name:"input1", maxLength:"6", type:"text" '/>
      <input id="input2_7" data-dojo-type="dijit.form.ValidationTextBox" data-dojo-props='name:"input1", maxLength:"6", type:"text" '/>
      <input id="input2_8" data-dojo-type="dijit.form.ValidationTextBox" data-dojo-props='name:"input1", maxLength:"6", type:"text" '/>
      <input id="input2_9" data-dojo-type="dijit.form.ValidationTextBox" data-dojo-props='name:"input1", maxLength:"6", type:"text" '/>
      <input id="input2_10" data-dojo-type="dijit.form.ValidationTextBox" data-dojo-props='name:"input1", maxLength:"6", type:"text" '/>
      <input id="input2_11" data-dojo-type="dijit.form.ValidationTextBox" data-dojo-props='name:"input1", maxLength:"6", type:"text" '/>
      <input id="input2_12" data-dojo-type="dijit.form.ValidationTextBox" data-dojo-props='name:"input1", maxLength:"6", type:"text" '/>
      <input id="input2_13" data-dojo-type="dijit.form.ValidationTextBox" data-dojo-props='name:"input1", maxLength:"6", type:"text" '/>
      <input id="input2_14" data-dojo-type="dijit.form.ValidationTextBox" data-dojo-props='name:"input1", maxLength:"6", type:"text" '/>
      <input id="input2_15" data-dojo-type="dijit.form.ValidationTextBox" data-dojo-props='name:"input1", maxLength:"6", type:"text" '/>
      <input id="input2_16" data-dojo-type="dijit.form.ValidationTextBox" data-dojo-props='name:"input1", maxLength:"6", type:"text" '/>
      <input id="input2_17" data-dojo-type="dijit.form.ValidationTextBox" data-dojo-props='name:"input1", maxLength:"6", type:"text" '/>
      <input id="input2_18" data-dojo-type="dijit.form.ValidationTextBox" data-dojo-props='name:"input1", maxLength:"6", type:"text" '/>
      <input id="input2_19" data-dojo-type="dijit.form.ValidationTextBox" data-dojo-props='name:"input1", maxLength:"6", type:"text" '/>
      <input id="input2_20" data-dojo-type="dijit.form.ValidationTextBox" data-dojo-props='name:"input1", maxLength:"6", type:"text" '/>
      </form>
      <br/>
      <button name="button" onclick="performancetest()">Run tests</button>
  </body>
</html>
